package com.example.demo.modules.demo.controller;

import com.example.demo.common.r2dbc.BaseController;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Controller
@RequestMapping("/dp")
public class DemoTemplateController extends BaseController {

    @GetMapping("/hello")
    public Mono<String> hello(ServerWebExchange webExchange, Model model, String name){
        return Mono.create(sink ->{
            String aName = name;
            if(StringUtils.isBlank(aName)){
                aName = "游客";
            }
            model.addAttribute("name", aName);
            sink.success("hello");
        });
    }
}
